import { UPDATEPAGECHOOSEDESIREJOB } from '../types/pagechoosedesirejob'
import { createAction } from 'redux-actions'
import { getIndustryCategoryRequest } from '../../../../service/user-archive-controller'

export const DOREQUESTCHOOSEDESIREJOB = createAction(UPDATEPAGECHOOSEDESIREJOB, (type) => {
  return new Promise(resolve => {
    getIndustryCategoryRequest(type).then(({ data }) => {
      const { networkerror, entry, status, message } = data
      if (networkerror) {
        resolve({
          networkerror: true
        })
      } else {
        if (status && entry) {
          resolve({
            networkerror: false,
            showEmpty: false,
            desireList: [...entry]
          })
        } else {
          resolve({
            networkerror: false,
            showEmpty: true
          })
        }
      }
    })
  })
})
